package swing;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.BorderFactory;

import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.LayoutStyle;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.LineBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class JFrameReporteAprobados extends javax.swing.JFrame {
	private JScrollPane jScrollPanelAprobados;
	private JTable jTableAprobados;
	private JLabel lblLogo;
	private JFormattedTextField jFormattedTextFieldSeccion;
	private JButton btnListo;
    JFrameCrearSeccion jfseccion = new JFrameCrearSeccion();
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrameReporteAprobados inst = new JFrameReporteAprobados();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public JFrameReporteAprobados() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
			jScrollPanelAprobados = new JScrollPane();
			{
				setTitle("Listado de Estudiantes Aprobados");
				getContentPane().setBackground(new java.awt.Color(255,255,255));

				TableModel jTableAprobadosModel = new DefaultTableModel(
					new String[][] { { "", "" }, { "", "" }},
					new String[] { "Cedula", "Nombre","Apellido","Nota Final" });
				jTableAprobados = new JTable();
				jTableAprobados.setEnabled(false);
				jScrollPanelAprobados.setViewportView(jTableAprobados);
				jTableAprobados.setModel(jTableAprobadosModel);
				
				if (JFrameCrearSeccion.secc.getAlumnos().size()>0){
				    JFrameCrearSeccion.secc.ordenarAlumnoCedula();
				    Estudiante estudiante;
				    int cont = 0;
			        for(int i=0;i<JFrameCrearSeccion.secc.getAlumnos().size();i++){
			    	  estudiante=JFrameCrearSeccion.secc.getAlumnos().elementAt(i);
			    	  if (estudiante.getNotaFinal()>=10){
			    	  jTableAprobados.setValueAt(estudiante.getCedula(),i,0);
			    	  jTableAprobados.setValueAt(estudiante.getNombre(),i,1);
			    	  jTableAprobados.setValueAt(estudiante.getApellido(),i,2);
			    	  jTableAprobados.setValueAt(estudiante.getNotaFinal(),i,3);
			    	  cont++;
			    	  }
			        }
			        if (cont==0)
			        	JOptionPane.showMessageDialog(null,"Listado vacio, no hay estudiantes aprobados en la seccion", "Listado de Estudiantes Ordenados por Cedula",JOptionPane.INFORMATION_MESSAGE);	
			    }
			    else
			      JOptionPane.showMessageDialog(null,"Listado vacio, no hay estudiantes inscritos", "Listado de Estudiantes Ordenados por Cedula",JOptionPane.INFORMATION_MESSAGE);
				
	      	}
				pack();
				this.setSize(472, 389);
				}
			{
				btnListo = new JButton();
				btnListo.setIcon(new ImageIcon(getClass().getResource("salir.jpeg")));
				btnListo.setBackground(new java.awt.Color(255,255,255));
				//jbtnsalir.setText("Salir");
				btnListo.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						System.out.println("jbtnsalir.mouseClicked, event="+evt);
						
						//TODO add your code for btnEstudiante.mouseClicked
						JFrameMenu jfest = new JFrameMenu();
	    				 jfest.setLocationRelativeTo(null);
	    				 jfest.setVisible(true);
	    				 setVisible(false);
					}
				});
			}
			{
				jFormattedTextFieldSeccion = new JFormattedTextField();
				jFormattedTextFieldSeccion.setText("Aprobados");
				jFormattedTextFieldSeccion.setEditable(false);
				jFormattedTextFieldSeccion.setBackground(new java.awt.Color(24,87,227));
				jFormattedTextFieldSeccion.setForeground(new java.awt.Color(255,255,255));
				jFormattedTextFieldSeccion.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
			}
			{
				lblLogo = new JLabel();
				lblLogo.setIcon(new ImageIcon(getClass().getResource("escudo.jpeg")));
			}
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
					.addGroup(thisLayout.createParallelGroup()
					    .addComponent(lblLogo, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 73, GroupLayout.PREFERRED_SIZE)
					    .addGroup(thisLayout.createSequentialGroup()
					        .addGap(19)
					        .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					            .addComponent(btnListo, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
					            .addComponent(jFormattedTextFieldSeccion, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(jScrollPanelAprobados, 0, 268, Short.MAX_VALUE)
					.addContainerGap());
				thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
				.addGap(6)
				.addGroup(thisLayout.createParallelGroup()
				    .addComponent(jScrollPanelAprobados, GroupLayout.Alignment.LEADING, 0, 449, Short.MAX_VALUE)
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addGap(23)
				        .addComponent(lblLogo, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
				        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				        .addComponent(jFormattedTextFieldSeccion, GroupLayout.PREFERRED_SIZE, 264, GroupLayout.PREFERRED_SIZE)
				        .addGap(18)
				        .addComponent(btnListo, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 36, Short.MAX_VALUE)))
				.addGap(7));
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
